package com.shenzhen.horselive.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;

import com.shenzhen.horselive.R;
import com.shenzhen.horselive.databinding.DialogLoginBinding;
import com.shenzhen.horselive.widget.actionsheet.ActionSheet;

public class CommentDialog extends Dialog {

    private OnClickButton   onClickButton;

    public void setOnClickButton(OnClickButton onClickButton) {
        this.onClickButton = onClickButton;
        binding.btCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (onClickButton!=null)
                {
                    onClickButton.cancel();
                }
            }
        });

        binding.btGo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (onClickButton!=null)
                {
                    onClickButton.confirm();
                }
            }
        });
    }

    public CommentDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    public CommentDialog(Context context, int theme) {
        super(context, theme);
    }


    DialogLoginBinding   binding;
    public CommentDialog(Context context) {
        super(context, R.style.CommonDialog);
        //初始化
        binding = DialogLoginBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());


    }

    @Override
    public void show() {
        super.show();
        WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
        layoutParams.width= ViewGroup.LayoutParams.MATCH_PARENT;
        layoutParams.height= ViewGroup.LayoutParams.MATCH_PARENT;
        getWindow().setAttributes(layoutParams);
    }

    //titile
public  void  setTitleText(String  title)
{
    binding.tvText.setText(title);
}
//内容
    public  void  setContent(String  content)
    {
        binding.linerLogo.setVisibility(View.GONE);
        binding.tvContent.setVisibility(View.VISIBLE);
        binding.tvContent.setText(content);
    }

    public  void   setBtText(String cacel,String  confirm)
    {
        binding.btCancel.setText(cacel);
        binding.btGo.setText(confirm);
    }
    //确认
    public void setConfirm(View.OnClickListener onClickListener) {
        binding.btGo.setOnClickListener(onClickListener);
    }

    //取消
    public  void  setCancel(View.OnClickListener  onClickListener)
    {

        binding.btCancel.setOnClickListener(onClickListener);
    }



    public  interface  OnClickButton{
        void  confirm();
        void  cancel();
    }

}
